package com.study.util;

import com.study.pojo.user;

import java.util.ArrayList;
import java.util.List;

/**
 * @program: myProject
 * @description:
 *  分页工具类
 * @author: lan
 * @create: 2021-05-21 10:40
 * @version:1.0
 **/
public class PageUtil {


    public static List<user> page(List<user> users,
                                  Integer pageSize,
                                  Integer pageNum){
        List<user> rs = new ArrayList<>();
        int num1 = pageSize*(pageNum-1);
        int num2 = pageNum*pageSize;

        if(pageNum*pageSize>users.size()){
            num2 = users.size();
        }
        for (int i = num1; i < num2; i++) {
            // System.out.println(users.get(i));
            rs.add(users.get(i));
        }
        return rs;
    }


}
